<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人中心 - 南开大学搜索引擎</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
        }
        .container {
            max-width: 960px;
            margin: 0 auto;
            padding: 20px;
        }
        .profile-header {
            background-color: #fff;
            padding: 30px;
            border-radius: 8px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
            text-align: center;
        }
        .profile-header h1 {
            font-size: 24px;
            color: #333;
            margin: 0 0 10px 0;
        }
        .profile-header p {
            font-size: 16px;
            color: #5E2D9B;
            margin: 0;
        }
        .card {
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
            margin-bottom: 20px;
            padding: 20px;
        }
        .card-header {
            border-bottom: 1px solid #eee;
            padding-bottom: 15px;
            margin-bottom: 15px;
        }
        .card-header h2 {
            font-size: 18px;
            color: #333;
            margin: 0;
        }
        .search-history {
            list-style: none;
            padding: 0;
            margin: 0;
        }
        .history-item {
            padding: 12px 0;
            border-bottom: 1px solid #eee;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .history-item:last-child {
            border-bottom: none;
        }
        .history-query {
            font-size: 16px;
            color: #1a0dab;
            cursor: pointer;
            text-decoration: none;
        }
        .history-query:hover {
            text-decoration: underline;
        }
        .history-meta {
            font-size: 14px;
            color: #777;
        }
        .history-type {
            font-size: 12px;
            padding: 3px 8px;
            border-radius: 12px;
            margin-left: 10px;
        }
        .type-web {
            background-color: #e3f2fd;
            color: #0d47a1;
        }
        .type-doc {
            background-color: #e8f5e9;
            color: #1b5e20;
        }
        .type-all {
            background-color: #f5f5f5;
            color: #616161;
        }
        .nav-links {
            text-align: center;
            margin-top: 30px;
        }
        .nav-links a {
            color: #1a0dab;
            text-decoration: none;
            margin: 0 10px;
        }
        .nav-links a:hover {
            text-decoration: underline;
        }
        .empty-history {
            text-align: center;
            padding: 30px 0;
            color: #777;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="profile-header">
            <h1>个人中心</h1>
            <p>用户名: {{ username }}</p>
        </div>
        
        <div class="card">
            <div class="card-header">
                <h2>我的搜索历史</h2>
            </div>
            
            {% if history and history|length > 0 %}
            <ul class="search-history">
                {% for item in history %}
                <li class="history-item">
                    <a href="/?q={{ item.query }}" class="history-query">{{ item.query }}</a>
                    <div class="history-meta">
                        <span class="history-time">{{ item.timestamp }}</span>
                        <span class="history-type type-{{ item.type }}">{{ item.type }}</span>
                    </div>
                </li>
                {% endfor %}
            </ul>
            {% else %}
            <div class="empty-history">
                <p>您还没有搜索历史记录</p>
            </div>
            {% endif %}
        </div>
        
        <div class="nav-links">
            <a href="/">返回首页</a>
            <a href="/logout">退出登录</a>
        </div>
    </div>
    
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // 点击历史记录时，将查询参数存储到会话中
            document.querySelectorAll('.history-query').forEach(function(link) {
                link.addEventListener('click', function(e) {
                    const query = this.textContent;
                    sessionStorage.setItem('last_search_query', query);
                });
            });
        });
    </script>
</body>
</html> 